package com.demo.web.services;

import com.demo.web.po.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.ArrayList;

/**
 * @author peter
 * @date 2022/2/27 0:00
 */
@Service
@Slf4j
public class UserServices {

    private static ArrayList<User> users = new ArrayList<>();

    @PostConstruct
    public void init(){
        User peter = new User("peter", 18);
        User andy = new User("andy", 18);

        users.add(peter);
        users.add(andy);
        log.info("Users初始化：" + users.toString());
    }

    /**
     * 获取所有用户列表
     *
     * @return ArrayList<User> 用户信息
     */
    public ArrayList<User> getAllUsers() {
        return users;
    }
}
